﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Hydra.Contract;

namespace Hydra.Reciever
{
    public class Host
    {
        private static ServiceHost host;

        public static void Start()
        {
            HydraService service = new HydraService();
            Uri address = Constants.Endpoint;
            host = new ServiceHost(service, address);
            host.AddServiceEndpoint(typeof(IHydraService), Constants.Binding, string.Empty);

            host.Open();
            Console.WriteLine("Press enter key to exit.");
        }

        public static void Stop()
        {
            host.Close();
        }

        public static IHydraCallback Agent
        {
            get
            {
                return host.SingletonInstance as IHydraCallback;
            }
        }
    }
}
